﻿#nullable disable
using Microsoft.AspNetCore.Mvc;
using Web.Controllers.Filter;

namespace Web.Controllers
{
    /// <summary>
    /// 基类Controller
    /// </summary>
#if !DEBUG
    [CustomOAuth(null)]//微信普通授权过滤器，OAuthScope.snsapi_base方式授权
#endif
    public class BaseController : Controller
    {
        #region 变量与属性
        /// <summary>
        /// 每个公众号appId
        /// </summary>
        public string appId
        {
            get
            {
                return CoreHelper.AppSettingsManager.Get("SenparcWeixinSetting:WeixinAppId");
            }
        }
        /// <summary>
        /// 域名
        /// </summary>
        public string DomainUrl
        {
            get
            {
                return AppSettingsManager.Get("basesetting:DomainUrl");
            }
        }


        /// <summary>
        /// 当前用户openid
        /// </summary>
        public string CurrentUserOpenid
        {
            get
            {
#if DEBUG
                //本地测试时使用
                string openid = CoreHelper.AppSettingsManager.Get("basesetting:testOpenid");
#else
                string openid = User.Identity.Name;
#endif
                return openid;
            }
        }
        #endregion

    }
}